<!--# layout("/common/layout.html",{"jsBase":"/js/admin/org/"}){ -->
<style>
	.ubList{
		height: auto;
		max-height: 350px;
		border: 1px solid;
		border-color: #D2D2D2!important;
		width: 438px;
		margin:-1px 130px;
		border-radius: 5px;
		position: absolute;
		z-index: 100;
		background-color: white;
		overflow-y:scroll;
		display:none;
	}
	.ubName{
		margin-top: 5px;
		margin-bottom: 10px;
		height: 35px;
		line-height: 35px;
		width: 100%;
		cursor: pointer;
	}
	.ubName:hover{
		background-color: #E8E8E8;
	}
</style>
<form class="layui-form layui-form-pane" id="updateForm" >
	<div class="layui-row">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">事业部名<em style="color: red;">*</em></label>
				<div class="layui-input-inline">
					<input type="text" name="name" autocomplete="off" lay-verify="required" placeholder="请输入标题" class="layui-input" value="${org.name}">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">事业部代码<em style="color: red;">*</em></label>
				<div class="layui-input-inline">
					<input type="text" name="code" readonly lay-verify="required" autocomplete="off" class="layui-input" value="${org.code}">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">事业部负责人</label>
			<div class="layui-input-inline" style="width: 440px;">
				<input type="hidden" id="stafId" name="stafId" value="${org.stafId}">
				<input type="text" id="userNm" class="layui-input" value="${org.userName}" placeholder="输入姓名或手机号搜索">
			</div>
			<span class="layui-btn" style="margin-left: -10px;" onclick="getUserList()"><i class="layui-icon">&#xe615;</i>搜索</span>
			<div class="ubList" id="ubList"></div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">所在父事业部<em style="color: red;">*</em></label>
					<layui:orgInputEdit style='layui-input-inline' name="parentOrgId" id="parentOrgId"
								value="${org.parentOrgId}"></layui:orgInputEdit>
			</div>

		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">事业部类型<em style="color: red;">*</em></label>
				<div class="layui-input-inline">
					<layui:simpleDictSelect style='layui-input-inline' type="org_type" id="type" name="type" value="${org.type}" />
				</div>
			</div>
		</div>
	</div>
	<layui:submitButtons id="saveOrg" />
	<input type="hidden" name="id" value=${org.id} id="orgId"/>
</form>
<!--#} -->
<script>
layui.use(['edit'], function(){
  var orgEdit = layui.edit;
  orgEdit.init();
    $("body").click(function(){
        $("#ubList").html("");
        $("#ubList").hide();
    })
});

//查询用户
function getUserList(){
    var userName = $("#userNm").val();
    if(userName.length <= 0){
        Common.info("请输入姓名或手机号");
        return;
    }
    Common.post("/approvalProcess/approvalProcess/selectUser.json",{"userName":userName},function(data){
        var userList = data.userList;
		var list ="";
		for (var i =0 ;i< userList.length ;i++) {
			var uName = userList[i]["userName"];
			var userId = userList[i]["id"];
			var orgName = userList[i]["orgName"];
			if(orgName != null){
				list += "<div class=\"ubName\" onclick=\"checkUser('"+userId+"','"+uName+"')\"><span style=\"margin-left: 10px;\">"+orgName+"—"+uName+"</span></div>"
			}
		}
		if(list == ""){
			list += "<div class=\"ubName\"><span style=\"margin-left: 10px;\">无数据</span></div>"
		}
		$("#ubList").show();
		$("#ubList").html(list)
    })
}
//获取中用户
function checkUser(userId,uName) {
    $("#userNm").val(uName);
    $("#stafId").val(userId);
    $("#ubList").html("");
    $("#ubList").hide();
}
</script>

